<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body {
            position: relative;
            width: 1440px;
            height: 800px;
            background: url(./img/2.jpg) no-repeat;
            background-size: cover;
        }
        
        .baiDu {
            position: absolute;
            width: 800px;
            height: 100px;
            display: flex;
            left: 350px;
            top: 200px;
        }
        
        .baiDu li {
            list-style: none;
            width: 150px;
            height: 100px;
        }
        
        li img {
            width: 150px;
            height: 100px;
        }
    </style>
</head>

<body>
    <ul class="baiDu">
        <li><img src="./img/2.jpg"></li>
        <li><img src="./img/3.jpg"></li>
        <li><img src="./img/4.jpg"></li>
        <li><img src="./img/5.jpg"></li>
    </ul>
    <script>
        // 1.获取元素
        var div = document.querySelector('.baiDu').querySelectorAll('img');
        // 2.注册事件
        for (var i = 0; i < div.length; i++) {
            div[i].onclick = function() {
                document.body.style.backgroundImage = 'url(' + this.src + ')';
            }
        }
    </script>
</body>

</html>